package com.sc.study.ar.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.sc.common.annotation.Log;
import com.sc.common.core.controller.BaseController;
import com.sc.common.core.domain.AjaxResult;
import com.sc.common.enums.BusinessType;
import com.sc.study.ar.domain.ScSubjectTableAppraise;
import com.sc.study.ar.service.IScSubjectTableAppraiseService;
import com.sc.common.utils.poi.ExcelUtil;
import com.sc.common.core.page.TableDataInfo;

/**
 * 课程评价Controller
 * 
 * @author sc
 * @date 2022-03-14
 */
@RestController
@RequestMapping("/study/subjecttableappraise")
public class ScSubjectTableAppraiseController extends BaseController
{
    @Autowired
    private IScSubjectTableAppraiseService scSubjectTableAppraiseService;

    /**
     * 查询课程评价列表
     */
    @PreAuthorize("@ss.hasPermi('study:subjecttableappraise:list')")
    @GetMapping("/list")
    public TableDataInfo list(ScSubjectTableAppraise scSubjectTableAppraise)
    {
        startPage();
        List<ScSubjectTableAppraise> list = scSubjectTableAppraiseService.selectScSubjectTableAppraiseList(scSubjectTableAppraise);
        return getDataTable(list);
    }

    /**
     * 导出课程评价列表
     */
    @PreAuthorize("@ss.hasPermi('study:subjecttableappraise:export')")
    @Log(title = "课程评价", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ScSubjectTableAppraise scSubjectTableAppraise)
    {
        List<ScSubjectTableAppraise> list = scSubjectTableAppraiseService.selectScSubjectTableAppraiseList(scSubjectTableAppraise);
        ExcelUtil<ScSubjectTableAppraise> util = new ExcelUtil<ScSubjectTableAppraise>(ScSubjectTableAppraise.class);
        util.exportExcel(response, list, "课程评价数据");
    }

    /**
     * 获取课程评价详细信息
     */
    @PreAuthorize("@ss.hasPermi('study:subjecttableappraise:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(scSubjectTableAppraiseService.selectScSubjectTableAppraiseById(id));
    }

    /**
     * 新增课程评价
     */
    @PreAuthorize("@ss.hasPermi('study:subjecttableappraise:add')")
    @Log(title = "课程评价", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ScSubjectTableAppraise scSubjectTableAppraise)
    {
        return toAjax(scSubjectTableAppraiseService.insertScSubjectTableAppraise(scSubjectTableAppraise));
    }

    /**
     * 修改课程评价
     */
    @PreAuthorize("@ss.hasPermi('study:subjecttableappraise:edit')")
    @Log(title = "课程评价", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ScSubjectTableAppraise scSubjectTableAppraise)
    {
        return toAjax(scSubjectTableAppraiseService.updateScSubjectTableAppraise(scSubjectTableAppraise));
    }

    /**
     * 删除课程评价
     */
    @PreAuthorize("@ss.hasPermi('study:subjecttableappraise:remove')")
    @Log(title = "课程评价", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(scSubjectTableAppraiseService.deleteScSubjectTableAppraiseByIds(ids));
    }
}
